package com.hqyj.javaGraduation.account.dao;

import com.hqyj.javaGraduation.account.pojo.User;
import com.hqyj.javaGraduation.hotel.pojo.UtMenuInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

@Mapper
@Repository
public interface UserDao {

    @Select("select * from account_user where user_account=#{userAccount} and user_password=#{userPassword}")
    User userLogin(User user);

    @Insert("insert into account_user(user_name,user_sex,user_age,user_adress,user_account,user_password," +
            "user_create_date,user_email,user_ipone,user_member,user_integral) values" +
            "(#{userName},#{userSex},#{userAge},#{userAddress},#{userAccount},#{userPassword},now(),#{userEmail}" +
            ",#{userIpone},#{userMember},#{userIntegral})")
    @Options(useGeneratedKeys = true, keyColumn = "user_id", keyProperty = "userId")
    int Register(User user);

    // 查询会员等级
    @Select("select * from account_user where user_id = #{utMenuInfo.userId}")
    User queryUserMember(@Param("utMenuInfo") UtMenuInfo utMenuInfo);

    @Update("update account_user set user_password = #{userPassword} where user_account = #{userAccount}")
    int updatePwd(User user);
}
